pkgname=firmware-fairphone-fp3
pkgver=20210805
_commit="ee529820bb874ab1b52873f0b144c3786f01ee4c"
pkgrel=1
pkgdesc="Firmware for Fairphone 3"
url="https://github.com/FairBlobs/FP3-firmware"
arch="aarch64"
license="proprietary"
subpackages="
	$pkgname-adreno
	$pkgname-adsp
	$pkgname-modem
	$pkgname-venus
	$pkgname-wcnss
	"
options="!check !strip !archcheck !tracedeps pmb:cross-native"
source="https://github.com/FairBlobs/FP3-firmware/archive/$_commit/FP3-firmware-$_commit.tar.gz"
builddir="$srcdir/FP3-firmware-$_commit"
_fwdir="/lib/firmware"

package() {
	mkdir -p "$pkgdir"
}

adreno() {
	pkgdesc="Fairphone 3 firmware for GPU"

	install -Dm644 "$builddir"/a506_zap.mdt -t \
		"$subpkgdir/$_fwdir/qcom/msm8953/fairphone/fp3"
	install -Dm644 "$builddir"/a506_zap.b* -t \
		"$subpkgdir/$_fwdir/qcom/msm8953/fairphone/fp3"
	install -Dm644 "$builddir"/a530_pm4.fw -t \
		"$subpkgdir/$_fwdir/qcom/msm8953/fairphone/fp3"
	install -Dm644 "$builddir"/a530_pfp.fw -t \
		"$subpkgdir/$_fwdir/qcom/msm8953/fairphone/fp3"
}

adsp() {
	pkgdesc="Fairphone 3 firmware for the ADSP"

	install -Dm644 "$builddir"/adsp.* -t \
		"$subpkgdir/$_fwdir/postmarketos"
}

modem() {
	pkgdesc="Fairphone 3 firmware for the modem"

	install -Dm644 "$builddir"/mba.mbn -t \
		"$subpkgdir/$_fwdir/postmarketos"
	install -Dm644 "$builddir"/modem.* -t \
		"$subpkgdir/$_fwdir/postmarketos"
}

venus() {
	pkgdesc="Fairphone 3 firmware for venus"

	install -Dm644 "$builddir"/venus.* -t \
		"$subpkgdir/$_fwdir/postmarketos"
}

wcnss() {
	pkgdesc="Fairphone 3 firmware for the Qualcomm Wireless Connectivity Subsystem (WCNSS)"

	install -Dm644 "$builddir"/wcnss.* -t \
		"$subpkgdir/$_fwdir/postmarketos"
	install -Dm644 "$builddir"/wlan/prima/* -t \
		"$subpkgdir/$_fwdir/postmarketos"/wlan/prima
}

sha512sums="
efa827787814ff4a59a0a61ca66410e46ce0add29b1451b4962b2d8af1d52b7035a0550b188fd442358702252964e4b64b16f836c5dcb1f748102cd0550aff7b  FP3-firmware-ee529820bb874ab1b52873f0b144c3786f01ee4c.tar.gz
"
